package com.station.Activitys.utils;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

/**
 * 项目名称：
 * 类描述：Activity 之间的跳转
 * 创建人：张飞祥
 * 创建时间：2018/04/18 下午2:17
 * 修改人：张飞祥
 * 修改时间：2018/04/18 下午2:17
 * 修改备注：
 */
public class JumperUtils {

    public static void JumpTo(Activity activity, Class<?> cls) {
        try {
            Intent intent = new Intent(activity, cls);
            activity.startActivity(intent);
        } catch (ActivityNotFoundException e) {

        } catch (NullPointerException e) {

        }
    }

    public static void JumpTo(Activity activity, Class<?> cls, Bundle bundle) {
        try {
            Intent intent = new Intent(activity, cls);
            intent.putExtras(bundle);
            activity.startActivity(intent);
        } catch (ActivityNotFoundException e) {

        } catch (NullPointerException e) {

        }
    }


    public static void JumpToForResult(Activity activity, Class<?> cls, int requestCode) {
        try {
            Intent intent = new Intent(activity, cls);
            activity.startActivityForResult(intent, requestCode);
        } catch (ActivityNotFoundException e) {

        } catch (NullPointerException e) {

        }
    }


    public static void JumpToForResult(Activity activity, Class<?> cls, int requestCode, Bundle bundle) {
        try {
            Intent intent = new Intent(activity, cls);
            intent.putExtras(bundle);
            activity.startActivityForResult(intent, requestCode);
        } catch (ActivityNotFoundException e) {

        } catch (NullPointerException e) {

        }
    }

    public static void JumpTo(Activity activity, String url) {
        try {
            Uri uri = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            activity.startActivity(intent);
        } catch (ActivityNotFoundException e) {

        } catch (NullPointerException e) {

        }
    }
}
